﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PackItem : MonoBehaviour {

    public Image goodIcon;
    public Text countText;

    public void Awake()
    {
        this.goodIcon = this.transform.FindChild("GoodIcom").GetComponent<Image>();
        this.countText = this.transform.FindChild("Text").GetComponent<Text>();
    }

    public void SetModel(PackModel packModel)
    {
        if (packModel.count == 0)
        {
            this.goodIcon.enabled = false;
            this.countText.text = string.Empty;
        }
        else
        {
            this.goodIcon.enabled = true;
            this.goodIcon.sprite = Resources.Load<Sprite>(GoodProxy.GetIntance().GetModelByID(packModel.GoodID).GoodIconPath);
            this.countText.text = packModel.count.ToString();
        }
    }
}
